home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZWindowManager.h -- desktop class; handles floaters
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
- #pragma once
-
- #ifndef __ZWINDOWMANAGER__
- #define __ZWINDOWMANAGER__
-
- #ifndef __ZOBJECTARRAY__
- #include "ZObjectArray.h"
- #endif
-
- class ZWindow;
-
-
- // container class definition for window list
-
- typedef ZObjectArray<ZWindow> ZWindowList;
-
-
- // window manager class
-
- class ZWindowManager
- {
- friend class ZMenuBar;
-
- protected:
-
- ZWindowList* nonFloaters; // list of non-floating windows
- ZWindowList* floaters; // list of floating windows
- ZWindowList* wmWindows; // list of windows in menu
- MenuHandle wmMenu; // handle of "Windows" menu if any
- short wmItemOffset; // item count of initial number of items in menu
- Point globalPlaceLoc; // placement position
-
- public:
-
- ZWindowManager();
- virtual ~ZWindowManager();
-
- virtual void AddWindow( ZWindow* aWindow );
- virtual void RemoveWindow( ZWindow* aWindow );
-
- virtual void HideWindow( ZWindow* aWindow );
- virtual void ShowWindow( ZWindow* aWindow );
-
- virtual void SelectWindow( ZWindow* aWindow );
- virtual void DragWindowOutline( ZWindow* aWindow, Point startPt, const short modifiers );
-
- virtual void Suspend();
- virtual void Resume();
- virtual void Deactivate();
- virtual void Activate();
-
- virtual ZWindow* GetTopWindow();
- virtual ZWindow* GetTopFloater();
- virtual ZWindow* GetBottomFloater();
-
- virtual Boolean CheckDialogEvent( EventRecord* theEvent );
- virtual ZWindow* LocateWindow( const Point globalMouse );
- virtual ZWindow* GetNthWindow( const long n );
- virtual ZWindow* GetNthFloater( const long n );
- virtual Boolean IsDialog( ZWindow* aWindow );
-
- virtual Boolean GetUniqueUntitledName( Str255 wName );
- virtual void FloatIdle();
-
- virtual short CountWindows();
- virtual short CountFloaters();
-
- virtual void InitiallyPlace( ZWindow* aWindow );
-
- private:
- void BringBehind( ZWindow* aWindow, ZWindow* behindWindow );
- void PostActivation( ZWindow* aWindow, Boolean state );
- void CalcWindowRgns( ZWindow* aWindow, RgnHandle aRgn );
- void ShowHideFloater( ZWindow* aFloater, Boolean hide );
-
- protected: // these methods accessible to gMenuBar, but not user's code.
-
- virtual void SetWindowsMenu( MenuHandle aMenu );
- virtual void SelectWindowFromMenu( const short itemID );
- void BuildWindowsMenu();
- };
-
- // This object is created by the application and installed as the global gWindowManager.
- // Windows ask this object to manage their selection, etc instead of calling the Mac's
- // window manager directly. This allows us to have floaters in our app. Windows have a
- // "isFloater" flag, which is inited automatically by detecting which WDEF is used, though this
- // can be forced as needed. The event handler also calls this to manage certain window chores
- // like dragging, to make sure the Mac Window Manager is never given the chance to screw things
- // up for us.
-
- extern ZWindowManager* gWindowManager;
-
- // WARNING: You must not call high-level mac window-manager calls from your code within MacZoop.
- // Calls such as SelectWindow() and DragWindow() in particular will cause problems. FrontWindow()
- // must be used with caution, since it does not distinguish between floating and non-floating
- // windows. Methods are provided here and in ZApplication that provide the equivalent floater-
- // savvy functionality.
-
- // ZWindowManager compilation options:
-
- // HIG says that all floating windows are peers of one another and thus all show the active
- // state regardless of their ordering within their layer. Some programmers may prefer the
- // other common behaviour where only one floater is active at a time. To get this latter
- // behaviour, comment out the following define and recompile. n.b. windows will still receive
- // their activate/deactivate messages- this only affects the window hiliting.
-
- #define _ALL_FLOATERS_ACTIVE
-
- // this window manager does not allow activate events to be sent by the mac toolbox, but
- // instead calls the event handler directly with the relevant parameters. In most cases, your
- // code won't be aware of this, but if you really need to get a "real" activation event,
- // comment in the following define. This makes the window manager post a real activation event
- // instead of "faking" one.
-
- // #define _ACTIVATE_EVENTS_ARE_REAL
-
- // When a window is picked up by its title bar for dragging, it is first brought to the front
- // of its layer (unless the command key is down). This selection can result in a non-updated
- // area of the window appearing until the drag is completed, at which point the window is
- // refreshed. This is the normal behaviour. However, this window manager object can prevent
- // this by forcing the update to occur immediately. This may give better perceived performance,
- // since the user won't be waiting for the update to come along later. To get this behaviour,
- // comment in the following:
-
- #define _UPDATE_ON_SELECT
-
- // Similarly, in the same situation, we select the window before dragging it. This is not what
- // DragWindow does- it selects the window after dragging. If you really desire this behaviour
- // instead, comment in the following:
-
- //#define _DRAGWINDOW_COMPATIBLE
-
-
- // If you are taking advantage of the automatic support for a "WIndows" menu, you might want to
- // list the windows alphabetically. The default is to list them in order of creation. To list
- // alphabetically, commeny IN the following:
-
- // #define _ALPHABETICAL_WINDOWS_MENU
-
-
- #endif